<?php
// 应用公共文件
use think\facade\Route;

/**
 * @param $id
 * @return string
 */
function admin_captcha_img($id = '', $domid = ''): string
{
    $src = admin_captcha_src($id);

    $domid = empty($domid) ? $domid : "id='" . $domid . "'";

    return "<img src='{$src}' alt='captcha' " . $domid . " onclick='this.src=\"{$src}?\"+Math.random();' />";
}

/**
 * @param $config
 * @return string
 */
function admin_captcha_src($config = null): string
{
    return Route::buildUrl('/admin/verify_code' . ($config ? "/{$config}" : ''));
}

function isAdminLogin() {
    $admin = session(config("admin.session_user"));

    if (empty($admin)) {
        return false;
    }

    return true;
}